//
//  WodeqianbaoViewController.m
//  tianjin
//
//  Created by 鞠超 on 16/8/11.
//  Copyright © 2016年 jc. All rights reserved.
//

#import "WodeqianbaoViewController.h"

#import "WodeqianbaoTableViewCell.h"
#import "Qianbao_chongzhiViewController.h"
#import "Qiangbao_tixianViewController.h"

@interface WodeqianbaoViewController () <UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView * tableView;
//头视图
@property (nonatomic, strong) UIView * view_headBg;
//余额
@property (nonatomic, strong) UILabel * user_yue;

@end

@implementation WodeqianbaoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self p_navi];
    
    [self p_setupView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - navi
- (void)p_navi
{
    _btnLeft.hidden = YES;
    _lblLeft.hidden = YES;
    _btnRight.hidden = YES;
    _lblRight.hidden = YES;
    _topView.backgroundColor = [UIColor blackColor];
    
    _lblTitle.text = @"我的积分";
    _lblTitle.textColor = [UIColor whiteColor];
    _lblTitle.font = [UIFont systemFontOfSize:19];
    
    UIImageView * image_return = [[UIImageView alloc] initWithFrame:CGRectMake(15, 32, 10, 20)];
    image_return.image = [UIImage imageNamed:@"zuofanhui@2x.png"];
    [_topView addSubview:image_return];
    
    UIButton * btn_return = [UIButton buttonWithType:(UIButtonTypeSystem)];
    btn_return.frame = CGRectMake(10, 20, 35, 44);
    [_topView addSubview:btn_return];
    [btn_return addTarget:self action:@selector(btn_returnAction:) forControlEvents:(UIControlEventTouchUpInside)];
}

//左返回
- (void )btn_returnAction:(UIButton *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

//显示tabbar
- (void )viewWillAppear:(BOOL)animated
{
    [(AppDelegate *)[[UIApplication sharedApplication] delegate] hiddenTabBar];
}

#pragma mark - 布局
- (void )p_setupView
{
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT - 64) style:(UITableViewStylePlain)];
    self.tableView.backgroundColor = [UIColor whiteColor];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.tableFooterView = [[UIView alloc] init];
    [self.view addSubview:self.tableView];
    
    //注册
    [self.tableView registerClass:[WodeqianbaoTableViewCell class] forCellReuseIdentifier:@"cell_qianbao"];
}

#pragma mark - tableview代理
- (NSInteger )numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger )tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 13;
}

- (CGFloat )tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 90;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    WodeqianbaoTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell_qianbao" forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;

    
    return cell;
}

//头视图
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    [self p_headView];
    
    return self.view_headBg;
}

- (CGFloat )tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 150;
}

#pragma mark - 充值
- (void )btn_chongAction:(UIButton *)sender
{
//    NSLog(@"点击进入充值页面");
    
    Qianbao_chongzhiViewController * qianbao_chongzhiViewController = [[Qianbao_chongzhiViewController alloc] init];
    [self showViewController:qianbao_chongzhiViewController sender:nil];
}

#pragma mark - 提现
- (void )btn_tixianAction:(UIButton *)sender
{
//    NSLog(@"点击进入提现页面");
    
    Qiangbao_tixianViewController * qiangbao_tixianViewController = [[Qiangbao_tixianViewController alloc] init];
    [self showViewController:qiangbao_tixianViewController sender:nil];
}

#pragma mark - 头视图
- (void )p_headView
{
    self.view_headBg = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 155)];
    self.view_headBg.backgroundColor = [UIColor whiteColor];
    
    //
    UIView * view_Greenbg = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 100)];
    view_Greenbg.backgroundColor = navi_bar_bg_color;
    [self.view_headBg addSubview:view_Greenbg];
    
    UIView * view_line = [[UIView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH / 2 - 0.5, 30, 1, 40)];
    view_line.backgroundColor = [UIColor whiteColor];
    [view_Greenbg addSubview:view_line];
    
    //充值
    UIImageView * image_yue = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH / 10 - 10, 30, 25, 25)];
    image_yue.image = [UIImage imageNamed:@"sdyue_1@2x.png"];
    [view_Greenbg addSubview:image_yue];
    
    self.user_yue = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image_yue.frame) + 8, CGRectGetMinY(image_yue.frame), SCREEN_WIDTH / 2 - CGRectGetMaxX(image_yue.frame) - 13, 15)];
    self.user_yue.text = @"余额￥1000.0";
    self.user_yue.textColor = [UIColor whiteColor];
    self.user_yue.font = [UIFont systemFontOfSize:15];
    [view_Greenbg addSubview:self.user_yue];
    
    UILabel * lbl_chongzhi = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMinX(self.user_yue.frame), CGRectGetMaxY(self.user_yue.frame) + 10, 70, 15)];
    lbl_chongzhi.textColor = [UIColor whiteColor];
    lbl_chongzhi.text = @"充值";
    lbl_chongzhi.font = [UIFont systemFontOfSize:15];
    [view_Greenbg addSubview:lbl_chongzhi];
    
    //提现
    UIImageView * image_tixian = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH / 2 + SCREEN_WIDTH / 10, 30, 25, 20)];
    image_tixian.image = [UIImage imageNamed:@"yinghangka_1@2x.png"];
    [view_Greenbg addSubview:image_tixian];
    
    UILabel * tixian = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image_tixian.frame) + 8, CGRectGetMinY(image_tixian.frame), 70, 15)];
    tixian.text = @"提现";
    tixian.textColor = [UIColor whiteColor];
    tixian.font = [UIFont systemFontOfSize:15];
    [view_Greenbg addSubview:tixian];
    
    UILabel * lijitixian = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMinX(tixian.frame), CGRectGetMaxY(tixian.frame) + 10, 70, 15)];
    lijitixian.textColor = [UIColor whiteColor];
    lijitixian.text = @"立即提现";
    lijitixian.font = [UIFont systemFontOfSize:15];
    [view_Greenbg addSubview:lijitixian];

    UILabel * jilu_zhangdan = [[UILabel alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(view_Greenbg.frame) + 15, 100, 15)];
    jilu_zhangdan.text = @"进出账记录";
    jilu_zhangdan.font = [UIFont systemFontOfSize:17];
    [self.view_headBg addSubview:jilu_zhangdan];
    
    UIView * view_line1 = [[UIView alloc] initWithFrame:CGRectMake(0, 145, SCREEN_WIDTH, 10)];
    view_line1.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self.view_headBg addSubview:view_line1];
    
    //充值
    UIButton * btn_chong = [UIButton buttonWithType:(UIButtonTypeSystem)];
    btn_chong.frame = CGRectMake(CGRectGetMinX(image_yue.frame), CGRectGetMinY(image_yue.frame), SCREEN_WIDTH / 2 - CGRectGetMinX(image_yue.frame) - 10, 50);
    [view_Greenbg addSubview:btn_chong];
    [btn_chong addTarget:self action:@selector(btn_chongAction:) forControlEvents:(UIControlEventTouchUpInside)];
    
    //提现
    UIButton * btn_tixian = [UIButton buttonWithType:(UIButtonTypeSystem)];
    btn_tixian.frame = CGRectMake(CGRectGetMinX(image_tixian.frame), CGRectGetMinY(image_tixian.frame), SCREEN_WIDTH / 2 - CGRectGetMinX(image_yue.frame) - 20, 50);
    [view_Greenbg addSubview:btn_tixian];
    [btn_tixian addTarget:self action:@selector(btn_tixianAction:) forControlEvents:(UIControlEventTouchUpInside)];
}











@end
